home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2000 #5 / Amiga Plus CD - 2000 - No. 5.iso / Tools / Dev / fpc / amigaunits / diskfont.pas < prev    next >
Pascal/Delphi Source File  |  2000-01-01  |  4KB  |  196 lines

  1. {
  2.     This file is part of the Free Pascal run time library.
  3.  
  4.     A file in Amiga system run time library.
  5.     Copyright (c) 1998-2000 by Nils Sjoholm
  6.     member of the Amiga RTL development team.
  7.  
  8.     See the file COPYING.FPC, included in this distribution,
  9.     for details about the copyright.
  10.  
  11.     This program is distributed in the hope that it will be useful,
  12.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14.  
  15.  **********************************************************************}
  16.  
  17. unit diskfont;
  18.  
  19. INTERFACE
  20.  
  21. uses exec, graphics;
  22.  
  23. Const
  24.  
  25.     MAXFONTPATH         = 256;
  26.  
  27. Type
  28.  
  29.     pFontContents = ^tFontContents;
  30.     tFontContents = record
  31.         fc_FileName     : Array [0..MAXFONTPATH-1] of Char;
  32.         fc_YSize        : Word;
  33.         fc_Style        : Byte;
  34.         fc_Flags        : Byte;
  35.     end;
  36.  
  37.  
  38.    pTFontContents = ^tTFontContents;
  39.    tTFontContents = record
  40.     tfc_FileName  : Array[0..MAXFONTPATH-3] of Char;
  41.     tfc_TagCount  : Word;
  42.  
  43.     tfc_YSize     : Word;
  44.     tfc_Style,
  45.     tfc_Flags     : Byte;
  46.    END;
  47.  
  48.  
  49. Const
  50.  
  51.     FCH_ID              = $0f00;
  52.     TFCH_ID             = $0f02;
  53.     OFCH_ID             = $0f03;
  54.  
  55.  
  56.  
  57. Type
  58.  
  59.     pFontContentsHeader = ^tFontContentsHeader;
  60.     tFontContentsHeader = record
  61.         fch_FileID      : Word;
  62.         fch_NumEntries  : Word;
  63.     end;
  64.  
  65. Const
  66.  
  67.     DFH_ID              = $0f80;
  68.     MAXFONTNAME         = 32;
  69.  
  70. Type
  71.  
  72.     pDiskFontHeader = ^tDiskFontHeader;
  73.     tDiskFontHeader = record
  74.         dfh_DF          : tNode;
  75.         dfh_FileID      : Word;
  76.         dfh_Revision    : Word;
  77.         dfh_Segment     : Longint;
  78.         dfh_Name        : Array [0..MAXFONTNAME-1] of Char;
  79.         dfh_TF          : tTextFont;
  80.     end;
  81.  
  82. Const
  83.  
  84.     AFB_MEMORY          = 0;
  85.     AFF_MEMORY          = 1;
  86.     AFB_DISK            = 1;
  87.     AFF_DISK            = 2;
  88.     AFB_SCALED          = 2;
  89.     AFF_SCALED          = $0004;
  90.     AFB_BITMAP          = 3;
  91.     AFF_BITMAP          = $0008;
  92.     AFB_TAGGED          = 16;
  93.     AFF_TAGGED          = $10000;
  94.  
  95.  
  96. Type
  97.  
  98.     pAvailFonts = ^tAvailFonts;
  99.     tAvailFonts = record
  100.         af_Type         : Word;
  101.         af_Attr         : tTextAttr;
  102.     end;
  103.  
  104.     pTAvailFonts = ^tTAvailFonts;
  105.     tTAvailFonts = record
  106.         taf_Type        : Word;
  107.         taf_Attr        : tTTextAttr;
  108.     END;
  109.  
  110.     pAvailFontsHeader = ^tAvailFontsHeader;
  111.     tAvailFontsHeader = record
  112.         afh_NumEntries  : Word;
  113.     end;
  114.  
  115. const
  116.     DISKFONTNAME : PChar = 'diskfont.library';
  117.  
  118. VAR DiskfontBase : pLibrary;
  119.  
  120. FUNCTION AvailFonts(buffer : pCHAR; bufBytes : LONGINT; flags : LONGINT) : LONGINT;
  121. PROCEDURE DisposeFontContents(fontContentsHeader : pFontContentsHeader);
  122. FUNCTION NewFontContents(fontsLock : BPTR; fontName : pCHAR) : pFontContentsHeader;
  123. FUNCTION NewScaledDiskFont(sourceFont : pTextFont; destTextAttr : pTextAttr) : pDiskFontHeader;
  124. FUNCTION OpenDiskFont(textAttr : pTextAttr) : pTextFont;
  125.  
  126. IMPLEMENTATION
  127.  
  128. FUNCTION AvailFonts(buffer : pCHAR; bufBytes : LONGINT; flags : LONGINT) : LONGINT;
  129. BEGIN
  130.   ASM
  131.     MOVE.L  A6,-(A7)
  132.     MOVEA.L buffer,A0
  133.     MOVE.L  bufBytes,D0
  134.     MOVE.L  flags,D1
  135.     MOVEA.L DiskfontBase,A6
  136.     JSR -036(A6)
  137.     MOVEA.L (A7)+,A6
  138.     MOVE.L  D0,@RESULT
  139.   END;
  140. END;
  141.  
  142. PROCEDURE DisposeFontContents(fontContentsHeader : pFontContentsHeader);
  143. BEGIN
  144.   ASM
  145.     MOVE.L  A6,-(A7)
  146.     MOVEA.L fontContentsHeader,A1
  147.     MOVEA.L DiskfontBase,A6
  148.     JSR -048(A6)
  149.     MOVEA.L (A7)+,A6
  150.   END;
  151. END;
  152.  
  153. FUNCTION NewFontContents(fontsLock : BPTR; fontName : pCHAR) : pFontContentsHeader;
  154. BEGIN
  155.   ASM
  156.     MOVE.L  A6,-(A7)
  157.     MOVEA.L fontsLock,A0
  158.     MOVEA.L fontName,A1
  159.     MOVEA.L DiskfontBase,A6
  160.     JSR -042(A6)
  161.     MOVEA.L (A7)+,A6
  162.     MOVE.L  D0,@RESULT
  163.   END;
  164. END;
  165.  
  166. FUNCTION NewScaledDiskFont(sourceFont : pTextFont; destTextAttr : pTextAttr) : pDiskFontHeader;
  167. BEGIN
  168.   ASM
  169.     MOVE.L  A6,-(A7)
  170.     MOVEA.L sourceFont,A0
  171.     MOVEA.L destTextAttr,A1
  172.     MOVEA.L DiskfontBase,A6
  173.     JSR -054(A6)
  174.     MOVEA.L (A7)+,A6
  175.     MOVE.L  D0,@RESULT
  176.   END;
  177. END;
  178.  
  179. FUNCTION OpenDiskFont(textAttr : pTextAttr) : pTextFont;
  180. BEGIN
  181.   ASM
  182.     MOVE.L  A6,-(A7)
  183.     MOVEA.L textAttr,A0
  184.     MOVEA.L DiskfontBase,A6
  185.     JSR -030(A6)
  186.     MOVEA.L (A7)+,A6
  187.     MOVE.L  D0,@RESULT
  188.   END;
  189. END;
  190.  
  191. END. (* UNIT DISKFONT *)
  192.  
  193.  
  194.  
  195.  
  196.